package java8;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.concurrent.*;

/**
 * @author lzy
 * @version v1.0
 * Create DateTime: 2018/7/21 9:47
 */
public class TestSimpleDateFormat {
    public static void main(String[] args) {
        SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
        ExecutorService pool = Executors.newFixedThreadPool(10);

        Callable<Date> call = () -> format.parse("20160304");

        Callable<Date> call2 = () -> SimpleDateThreadLocal.convert("20160304");

        List<Future<Date>> result = new ArrayList<>(10);

        for (int i = 0; i < 10; i++) {
            result.add(pool.submit(call2));
        }

        for (Future<Date> future : result) {
            try {
                System.out.println(future.get());
            } catch (InterruptedException | ExecutionException e) {
                e.printStackTrace();
            }
        }

        pool.shutdown();
    }

}
